"""
最大素因数

13195的素因数为5、7、13和29。求60051475143的最大素因数。
"""

def prime_factor(num):
    arr = []
    i = 2
    while num != 1:
        if num % i == 0:
            while num % i == 0:
                arr.append(i)
                num /= i
        i = i + 1
    return  max(arr)
print(prime_factor(13195))





# def getfactor(num):
#     arr = []
#     i = 2
#     while num != 1:
#         if num % i == 0:
#             while num % i == 0:
#                 arr.append(i)
#                 num /= i
#         i = i + 1
#     return  max(arr)
# print(getfactor(600851475143))
# 答案：6857

            
